Embodiments of the present invention relate to a method and system for cache management.
Cache means storing previously accessed contents in a local storage location, allowing a quick response to a subsequent access request for the same content. Caching technology is widely used in various fields such as computer processor, storage system, data system, and network application. For example, in a network environment, a web page or other network content previously accessed by a user may be cached locally in a client. When a user again accesses a web page that he/she has previously accessed, he/she may directly read the cached web page from a local storage, rather than again obtaining that web page through the internet from a remote server. This kind of caching typically shortens response time and reduces consumption of network bandwidth resources and server computing resources.
It is important in cache management to handle “cache invalidation.” Cache invalidation means the cached content is inconsistent with the actual latest version of the content, such that the cached content loses its original function. Cache invalidation is typically caused by backend update of the content. For example, when a web server updates the content in the web page, a cache item of the web page in the client will typically be invalidated. When a cache item is invalidated, it should be removed from the cache.
A time-based solution for managing cache invalidation is known. Each caching entry is assigned a fixed valid period. When the valid period expires, the corresponding cache entry is removed from the cache on the assumption that it has probably become invalid. However, in practice, this leads to: (i) deletion of cache entries that are still valid (because no invalidating changes have been made despite the passage of time); and (ii) some other cache entries might already have been invalidated prior to the expiration of the validity period.
Another kind of solution is handling cache invalidation based on event rules. Each cache entry may be associated with one or more predetermined events. When one of the predetermined events occurs, the corresponding cache entry will be determined invalid and deleted from the cache. However, in a distributed system involving multiple parties, the event-based cache invalidation management is difficult to implement. For example, in an internet e-commerce system, a web page is often cached on a content distribution network (CDN), enterprise server and client side. In such a case, a cross-system event trigger mechanism is required to manage cache invalidation. However, cross-system event trigger mechanisms are typically difficult to develop and maintain, so it may not be feasible to implement cache invalidation based on event rules for some applications.